/*
 * Created on Feb 26, 2011 by Eng. Julian Rousselot
 *  
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

package ar.com.visualAORE.view;

import java.awt.image.BufferedImage;


/**
 * @author julian
 *
 */
public class ZoomControl {
	public static BufferedImage zoomIn(BufferedImage bi, int scale)
	{
		int width = scale * bi.getWidth();
		int height = scale * bi.getHeight();
		
		BufferedImage biScale = new BufferedImage(width, height, bi.getType());
		
                // Cicla dando un valore medio al pixel corrispondente
		for(int i=0; i<width; i++)
			for(int j=0; j<height; j++)
				biScale.setRGB(i, j, bi.getRGB(i/scale, j/scale));
		
		return biScale;
	}
	
	public static BufferedImage zoomOut(BufferedImage bi, int scale)
	{
		int width = bi.getWidth() / scale;
		int height = bi.getHeight() / scale;
		
		BufferedImage biScale = new BufferedImage(width, height, bi.getType());
		
		for(int i=0; i<width; i++)
			for(int j=0; j<height; j++)
				biScale.setRGB(i, j, bi.getRGB(i*scale, j*scale));
		
		return biScale;
	}
}
